package main

import "fmt"

func main() {
	numbers := []int{0, 1, 2, 3, 4, 5, 6, 7, 8}
	printSlice(numbers)

	fmt.Println("numbers[1:4] ==", numbers[1:4])

	numbers1 := make([]int, 0, 5)
	printSlice(numbers1)

	number2 := numbers[:2]
	printSlice(number2)

	n3 := append(number2, 0)
	n3 = append(n3, 22, 33)
	printSlice(n3)

	var n4 []int = make([]int, 3, 5)
	for i := 1; i < 8; i++ {
		n4 = append(n4, i*10)
	}
	printSlice(n4)

	n5 := make([]int, len(n4), (cap(n4))*2)
	copy(n5, n4)
	printSlice(n5)
}

func printSlice(x []int) {
	fmt.Printf("len=%d cap=%d slice=%v\n", len(x), cap(x), x)
}
